package com.wondersgroup.fjzlpt.console.controller.rest.menu;

import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import com.wondersgroup.fjzlpt.console.feign.FormFeignService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.quick.framework.boot.web.utils.RequestUtils;
import com.wondersgroup.fjzlpt.console.service.inter.menu.MenuService;

@RestController
@RequestMapping("/menu")
public class MenuRestController {

	@Autowired
	private MenuService menuService;

	@RequestMapping("/queryMenu")
	public JSONArray queryMenu(HttpServletRequest request)
	{
		return menuService.queryMenu();
	}
	
	@RequestMapping("/save")
	public JSONObject save(HttpServletRequest request)
	{
		Map<String, String> map = RequestUtils.GetParameterMap(request);
		return menuService.save(map);
	}
	
	@RequestMapping("/delete")
	public JSONObject delete(HttpServletRequest request)
	{
		Map<String, String> map = RequestUtils.GetParameterMap(request);
		return menuService.delete(map);
	}
	@RequestMapping("/queryUnLinked")
	public JSONArray queryUnLinked(String name){
		try {
			name = URLDecoder.decode(name,"UTF-8");
		} catch (UnsupportedEncodingException e) {
		}
		return menuService.queryFormList(name,"false");
	}
}
